﻿using BO.Infrastructure.Utils;
using System;
using System.Data;

namespace GUI.Controls.News
{
    public partial class GiaoLuuTrucTuyen : System.Web.UI.UserControl
    {
        private const string FacebookLikeButtonFormat = "<iframe src=\"http://www.facebook.com/plugins/like.php?href={0}&amp;layout=standard&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;send=true\" scrolling=\"no\" frameborder=\"0\" style=\"border: none; overflow: hidden;height: 24px; width:440px; padding-right:5px;\" allowtransparency=\"true\"></iframe>";
        public int InterviewId { get; set; }


        public bool DataBind(DataTable dt, DateTime publishedDate, string detailedUrl, int interviewId, bool isEnd)
        {

            if (dt != null && dt.Rows.Count > 0)
            {
                InterviewId = interviewId;
                var r = dt.Rows[0];

                ltrTitle.Text = r["Title"].ToString();

                ltrSapo.Text = r["Summary"].ToString();
                //Page.ClientScript.RegisterClientScriptBlock(GetType(), string.Empty, string.Format("console.log('{0}');", PresentationUtils.EnCode(r["Summary"].ToString())), true);
                ltrContent.Text = r["Content"].ToString();
                ltrPublishDate.Text = publishedDate.ToString("dd/MM/yyyy HH:mm");

                ltrFacebookLikeButton.Text = string.Format(FacebookLikeButtonFormat, detailedUrl);

                divFormGiaoLuuTrucTuyen.Visible = !isEnd;


                return true;
            }
            return false;
        }


    }
}